package cn.lili.controller.feign.system;

import cn.lili.modules.sms.SmsUtil;
import cn.lili.modules.system.client.SmsClient;
import cn.lili.modules.system.entity.params.SmsParams;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author paulG
 * @since 2022/1/13
 **/
@RestController
@RequiredArgsConstructor
public class SmsFeignController implements SmsClient {

    private final SmsUtil smsUtil;

    /**
     * 验证码发送
     * @param smsParams
     */
    @Override
    public void sendSmsCode(SmsParams smsParams) {
        smsUtil.sendSmsCode(smsParams.getMobile(), smsParams.getVerificationEnums(), smsParams.getUuid());
    }


    /**
     * 验证码验证
     * @param smsParams
     * @return
     */
    @Override
    public boolean verifyCode(SmsParams smsParams) {
        return smsUtil.verifyCode(smsParams.getMobile(), smsParams.getVerificationEnums(), smsParams.getUuid(), smsParams.getCode());
    }


    /**
     * 短信发送
     * @param smsParams
     * @param templateCode
     */
    @Override
    public void sendSmsCode(SmsParams smsParams, String templateCode) {
        smsUtil.sendSmsCode(smsParams.getSignName(),smsParams.getMobile(), smsParams.getParam(), templateCode);
    }

    /**
     * 短信批量发送
     * @param smsParams
     */
    @Override
    public void sendBatchSms(SmsParams smsParams) {
        smsUtil.sendBatchSms(smsParams.getSignName(),smsParams.getMobiles(),smsParams.getTemplateCode());
    }
}
